<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jstl/core_rt" prefix="c-rt"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@page import="com.yaodian100.core.common.utils.ServerValue"%>
<c-rt:set var="midContextPath" value='<%=ServerValue.getMidContextPath() %>'/>
<c-rt:set var="midHostname" value='<%=ServerValue.getMidHostname()%>'/>
<style type="text/css">
.msg{float:left; line-height:1em; margin:0; display:block;border:1px solid #f66;padding:2px 5px;*padding:2px 5px 1px;}
.msg.rn{background-color:#fff2f2;border-color:#f66;}
</style>
<!-- 月历 -->
<script type="text/javascript" charset="UTF-8" src="/js/jquery.datepick.js"></script>
<script type="text/javascript" charset="UTF-8" src="/js/jquery.datepick-zh-CN.js"></script>
<link rel="stylesheet" type="text/css" href="/css/smoothness.datepick.css" />
<!-- 数字验证 -->
<script type="text/javascript" charset="UTF-8" src="/js/jquery.alphanumeric.js"></script>
<script type="text/javascript" charset="UTF-8" src="/js/yaodian100.common.js"></script>
<script type="text/javascript" charset="UTF-8" src="/js/jquery.autotab-1.1b.js"></script>
<script language="javascript">
	$().ready( function() {
		$(":input[id*='ProductId']").each(function(){
			$(this).numeric();
			$(this).change(function(){
				$(this).val(prodPadLeft($(this).val()));
				getProductInfo("${midContextPath}", $(this).attr("id") + "_ProductName", $(this).val());
			});
		});
		
		$(":input[name*='AdCode']").alphanumeric();
		$(":input[name*='AdCode']").autotab_filter({ format: 'custom', pattern: '[^a-zA-Z0-9]' });
		
		$('#startDate').datepick({minDate: new Date(), showOn:'both',numberOfMonths:2, buttonImageOnly: true, buttonImage: '/images/calendar.gif',dateFormat:"yy-mm-dd"}); 
		$('#endDate').datepick({minDate: new Date(),showOn: 'both',numberOfMonths:2, buttonImageOnly: true, buttonImage: '/images/calendar.gif',dateFormat:"yy-mm-dd"});

		$("#subBtn").click(function(){
			if ( validate_data() ){
				$("#advStatus").val("10");
				$("#mainForm").submit();
			}
		});

		$("#draftBtn").click(function(){
			if ( validate_data() ){
				$("#advStatus").val("00");
				$("#mainForm").submit();
			}
		});
		
		$("#canBtn").click(function(){
			if ( validate_data() ){
				$("#advStatus").val("90");
				$("#mainForm").submit();
			}
		});
	});
	
	function validate_data(){
		if ( $("#advName").val() == "" ){
			alert("请输入广告名称");
			$("#advName").focus();
			return false;
		}
		if ( $("#startDate").val() == ""){
			alert("请输入起始时间");
			$("#startDate").focus();
			return false;
		}
		if( $("#endDate").val() == "" ){
			alert("请输入结束时间");
			$("#endDate").focus();
			return false;
		}
		if ($("#startDate").val() + $("#startTime").val() >= $("#endDate").val() + $("#endTime").val()) {
			alert("起始时间必须早於结束时间");
			$("#endDate").focus();
			return false;
		}

		if( $("#recommendProductId1").val() == "" ){
			alert("请输入本周推荐的商品编号一");
			$("#recommendProductId1").focus();
			return false;
		}
		if( $("#recommendProductId2").val() == "" ){
			alert("请输入本周推荐的商品编号二");
			$("#recommendProductId2").focus();
			return false;
		}
		if( $("#recommendProductId3").val() == "" ){
			alert("请输入本周推荐的商品编号三");
			$("#recommendProductId3").focus();
			return false;
		}
		if( $("#freshProductId1").val() == "" ){
			alert("请输入新鲜货的商品编号一");
			$("#freshProductId1").focus();
			return false;
		}
		if( $("#freshProductId2").val() == "" ){
			alert("请输入新鲜货的商品编号二");
			$("#freshProductId2").focus();
			return false;
		}
		if( $("#freshProductId3").val() == "" ){
			alert("请输入新鲜货的商品编号三");
			$("#freshProductId3").focus();
			return false;
		}
		if( $("#topicalProductId1").val() == "" ){
			alert("请输入本月话题的商品编号一");
			$("#topicalProductId1").focus();
			return false;
		}
		if( $("#topicalProductId2").val() == "" ){
			alert("请输入本月话题的商品编号二");
			$("#topicalProductId2").focus();
			return false;
		}
		if( $("#topicalProductId3").val() == "" ){
			alert("请输入本月话题的商品编号三");
			$("#topicalProductId3").focus();
			return false;
		}
		return true;
	}

</script>

<h1>
	广告管理 - 首页右侧本周推荐
	<br/>
	<div class="f-link">
		<a href="${midContextPath}/generate/searchIdx.do">回广告查询页</a>
	</div>
</h1>
<s:if test="hasErrors()">
	<s:actionerror cssClass="msg rn" />
</s:if>
<s:if test="hasActionMessages()">
	<s:actionmessage cssClass="msg rn" />
</s:if>
<s:form action="idxWeeklyRecommendAdv/saveWeeklyRecommendAdv.do" method="post" name="mainForm" id="mainForm" enctype="multipart/form-data">
	<table class="tb-data" width="100%">
		<tbody>
			<tr>
				<th>类型</th>
				<td>
					首页右侧本周推荐
					<s:hidden name="adv.advType"></s:hidden>
				</td>
			</tr>
			<tr>
				<th>广告名称</th>
				<td>
					<s:textfield name="adv.advName" id="advName" size="30" maxlength="30" ></s:textfield>
					<s:if test="null != fieldErrors['idxWeeklyRecommendAdv.name']">
						<span class="msg rn"><s:fielderror><s:param>idxWeeklyRecommendAdv.name</s:param></s:fielderror></span>
					</s:if>
				</td>
			</tr>
			<tr>
				<th>起迄时间</th>
				<td>
					<s:textfield name="idxWeeklyRecommendAdv.startDate" id="startDate" maxlength="10" ></s:textfield>
					<select id="startTime" name="idxWeeklyRecommendAdv.startTime">			
						<c-rt:forEach begin="0" end="23" var="t1">
							<c-rt:if test="${t1<10}">
							<c-rt:set value="0${t1}:00" var="sTime"></c-rt:set>
							</c-rt:if>
							<c-rt:if test="${t1>=10}">
							<c-rt:set value="${t1}:00" var="sTime"></c-rt:set>
							</c-rt:if>
							<option value="${sTime}" <c-rt:if test="${sTime==idxImageAdv.startTime}">selected</c-rt:if>>${sTime}</option>
						</c-rt:forEach>
					</select>  
					~ 
					<s:textfield name="idxWeeklyRecommendAdv.endDate" id="endDate" maxlength="10" ></s:textfield>
					<select id="endTime" name="idxWeeklyRecommendAdv.endTime">
					<c-rt:forEach begin="0" end="23" var="t2" >
						<c-rt:set var="t3">${23-t2}</c-rt:set>	
						<c-rt:if test="${t3<10}">
						<c-rt:set value="0${t3}:59" var="eTime"></c-rt:set>
						</c-rt:if>
						<c-rt:if test="${t3>=10}">
						<c-rt:set value="${t3}:59" var="eTime"></c-rt:set>
						</c-rt:if>
						<option value="${eTime}" <c-rt:if test="${eTime==idxImageAdv.endTime }">selected</c-rt:if>>${eTime}</option>
					</c-rt:forEach>
					</select>
					<s:if test="null != fieldErrors['startDate']">
					<br/>
					<p><span class="msg rn"><s:fielderror><s:param>idxWeeklyRecommendAdv.startTime</s:param></s:fielderror></span></p>
					</s:if>
					<s:if test="null != fieldErrors['idxImageAdv.endTime']">
					<br/>
					</s:if>					
				</td>
			</tr>
			<tr>
				<th>本周推荐</th>
				<td>
					<table>
						<tr>
							<td>商品编号一</td>
							<td>
								<s:textfield name="idxWeeklyRecommendAdv.recommendProductId1" id="recommendProductId1"></s:textfield>
								<s:fielderror>
									<s:param>recommendProductId1</s:param>
								</s:fielderror>
								<span id="recommendProductId1_ProductName" >
									（请输入商品编号）
								</span>
							</td>
						</tr>
						<tr>
							<td>广告代码</td>
							<td>
								<s:textfield name="idxWeeklyRecommendAdv.recommendAdCode1" id="" size="25" maxLength="25" ></s:textfield>
								<span>
									非必填。由英文字母、数字组成，最多25个半角
								</span>
							</td>
						</tr>
						<tr>
							<td>商品编号二</td>
							<td>
								<s:textfield name="idxWeeklyRecommendAdv.recommendProductId2" id="recommendProductId2"></s:textfield>
								<s:fielderror>
									<s:param>recommendProductId2</s:param>
								</s:fielderror>
								<span id="recommendProductId2_ProductName" >
									（请输入商品编号）
								</span>
							</td>
						</tr>
						<tr>
							<td>广告代码</td>
							<td>
								<s:textfield name="idxWeeklyRecommendAdv.recommendAdCode2" id="" size="25" maxLength="25" ></s:textfield>
								<span>
									非必填。由英文字母、数字组成，最多25个半角
								</span>
							</td>
						</tr>
						<tr>
							<td>商品编号三</td>
							<td>
								<s:textfield name="idxWeeklyRecommendAdv.recommendProductId3" id="recommendProductId3"></s:textfield>
								<s:fielderror>
									<s:param>recommendProductId3</s:param>
								</s:fielderror>
								<span id="recommendProductId3_ProductName" >
									（请输入商品编号）
								</span>
							</td>
						</tr>
						<tr>
							<td>广告代码</td>
							<td>
								<s:textfield name="idxWeeklyRecommendAdv.recommendAdCode3" id="" size="25" maxLength="25" ></s:textfield>
								<span>
									非必填。由英文字母、数字组成，最多25个半角
								</span>
							</td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<th>新鲜货</th>
				<td>
					<table>
						<tr>
							<td>商品编号一</td>
							<td>
								<s:textfield name="idxWeeklyRecommendAdv.freshProductId1" id="freshProductId1"></s:textfield>
								<s:fielderror>
									<s:param>freshProductId1</s:param>
								</s:fielderror>
								<span id="freshProductId1_ProductName" >
									（请输入商品编号）
								</span>
							</td>
						</tr>
						<tr>
							<td>广告代码</td>
							<td>
								<s:textfield name="idxWeeklyRecommendAdv.freshAdCode1" id="" size="25" maxLength="25" ></s:textfield>
								<span>
									非必填。由英文字母、数字组成，最多25个半角
								</span>
							</td>
						</tr>
						<tr>
							<td>商品编号二</td>
							<td>
								<s:textfield name="idxWeeklyRecommendAdv.freshProductId2" id="freshProductId2"></s:textfield>
								<s:fielderror>
									<s:param>freshProductId2</s:param>
								</s:fielderror>
								<span id="freshProductId2_ProductName">
									（请输入商品编号）
								</span>
							</td>
						</tr>
						<tr>
							<td>广告代码</td>
							<td>
								<s:textfield name="idxWeeklyRecommendAdv.freshAdCode2" id="" size="25" maxLength="25" ></s:textfield>
								<span>
									非必填。由英文字母、数字组成，最多25个半角
								</span>
							</td>
						</tr>
						<tr>
							<td>商品编号三</td>
							<td>
								<s:textfield name="idxWeeklyRecommendAdv.freshProductId3" id="freshProductId3"></s:textfield>
								<s:fielderror>
									<s:param>freshProductId3</s:param>
								</s:fielderror>
								<span id="freshProductId3_ProductName">
									（请输入商品编号）
								</span>
							</td>
						</tr>
						<tr>
							<td>广告代码</td>
							<td>
								<s:textfield name="idxWeeklyRecommendAdv.freshAdCode3" id="" size="25" maxLength="25" ></s:textfield>
								<span>
									非必填。由英文字母、数字组成，最多25个半角
								</span>
							</td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<th>本月话题</th>
				<td>
					<table>
						<tr>
							<td>商品编号一</td>
							<td>
								<s:textfield name="idxWeeklyRecommendAdv.topicalProductId1" id="topicalProductId1"></s:textfield>
								<s:fielderror>
									<s:param>topicalProductId1</s:param>
								</s:fielderror>
								<span id="topicalProductId1_ProductName">
									（请输入商品编号）
								</span>
							</td>
						</tr>
						<tr>
							<td>广告代码</td>
							<td>
								<s:textfield name="idxWeeklyRecommendAdv.topicalAdCode1" id="" size="25" maxLength="25" ></s:textfield>
								<span>
									非必填。由英文字母、数字组成，最多25个半角
								</span>
							</td>
						</tr>
						<tr>
							<td>商品编号二</td>
							<td>
								<s:textfield name="idxWeeklyRecommendAdv.topicalProductId2" id="topicalProductId2"></s:textfield>
								<s:fielderror>
									<s:param>topicalProductId2</s:param>
								</s:fielderror>
								<span id="topicalProductId2_ProductName">
									（请输入商品编号）
								</span>
							</td>
						</tr>
						<tr>
							<td>广告代码</td>
							<td>
								<s:textfield name="idxWeeklyRecommendAdv.topicalAdCode2" id="" size="25" maxLength="25" ></s:textfield>
								<span>
									非必填。由英文字母、数字组成，最多25个半角
								</span>
							</td>
						</tr>
						<tr>
							<td>商品编号三</td>
							<td>
								<s:textfield name="idxWeeklyRecommendAdv.topicalProductId3" id="topicalProductId3"></s:textfield>
								<s:fielderror>
									<s:param>topicalProductId3</s:param>
								</s:fielderror>
								<span id="topicalProductId3_ProductName">
									（请输入商品编号）
								</span>
							</td>
						</tr>
						<tr>
							<td>广告代码</td>
							<td>
								<s:textfield name="idxWeeklyRecommendAdv.topicalAdCode3" id="" size="25" maxLength="25" ></s:textfield>
								<span>
									非必填。由英文字母、数字组成，最多25个半角
								</span>
							</td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td colspan="2">
					<s:hidden name="adv.id" id="advId" ></s:hidden>
					<s:hidden name="adv.advStatus" id="advStatus" ></s:hidden>
					<input type="button" id="subBtn" name="subBtn" value="发送"/>
					<input type="button" id="draftBtn" name="draftBtn" value="草稿"/>
					<input type="button" id="canBtn" name="canBtn" value="暂停"/>
				</td>
			</tr>												
		</tbody>
	</table>
</s:form>
<div class="f-link">
	<a href="${midContextPath}/generate/searchIdx.do">回广告查询页</a>
</div>